package com.ea.eadp.nexus.test.pageDefinition.pc;

import com.ea.eadp.nexus.test.common.PageOperation;
import com.ea.eadp.nexus.test.pageDefinition.BasePage;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

/**
 * Created by yimingcao on 11/21/2014.
 */
public class UpdateEmailPage extends BasePage {
    public UpdateEmailPage(WebDriver driver) {
        super(driver, UpdateEmailPage.class);
    }

    public void clickSkipButton()
    {
        driver.switchTo().window(this.operationWindowHandle);
        driver.findElement(By.xpath("//div[@class='panel-action-area']/a[1]")).click();
    }

    public void clickContinueButton()
    {
        driver.switchTo().window(this.operationWindowHandle);
        WebDriverWait wait = new WebDriverWait(driver, 5);
        WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id("continue-btn")));
        element.click();
    }

    public void enterNewEmailAddress(String newEmailAddress) throws InterruptedException {
        driver.switchTo().window(this.operationWindowHandle);
        WebDriverWait wait = new WebDriverWait(driver, 5);
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("newEmail")));
        PageOperation.SendKeyToElement(driver, "newEmail", newEmailAddress);
    }
}
